package com.honey.mybatis.generator;

import org.java.plugin.PluginLifecycleException;

import com.honey.compilation.java.AbstractJavaCompilation;
import com.honey.compilation.java.Field;
import com.honey.compilation.java.InnerClass;
import com.honey.compilation.java.InnerEnum;
import com.honey.compilation.java.Method;
import com.honey.core.CorePlugin;
import com.honey.core.compiler.CompilationException;
import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.core.notify.Signal;
import com.honey.core.types.FullyQualifiedJavaType;
import com.honey.core.utils.ObjectFactory;

/**
 * 生产java对象
 * @author Administrator
 *
 */
public abstract class AbstractProduceJavaCompilation {
	
	protected IntrospectSchema introspectSchema;
	
	protected IntrospectSchemaColumn introspectSchemaColumn ;
	
	protected MybatisPlugin mybatisPlugin ;
	
	public AbstractProduceJavaCompilation(MybatisPlugin mybatisPlugin,IntrospectSchema introspectSchema, IntrospectSchemaColumn introspectSchemaColumn){
		this.mybatisPlugin = mybatisPlugin;
		this.introspectSchema = introspectSchema;
		this.introspectSchemaColumn = introspectSchemaColumn;
	};
	
	/**
	 * 成产类
	 * @return
	 */
	public abstract AbstractJavaCompilation produceCompilation() throws CompilationException; 
			
	
	/**
	 * 生产导入的包
	 * @return
	 */
	public FullyQualifiedJavaType[] produceImportClass()throws CompilationException{
		;
		return null;
	}
	
	/**
	 * 生产属性
	 * @return
	 */
	public abstract Field[] produceFields() throws CompilationException;

	/**
	 * 生产方法
	 * @return
	 */
	public abstract Method[] produceMethods()throws CompilationException;
	
	/**
	 * 生产内部类
	 * @return
	 */
	public InnerClass[] produceInnerClass()throws CompilationException{
		return null;
	}

	/**
	 * 生产内部枚举
	 * @return
	 */
	public InnerEnum[] produceInnerEnumClass()throws CompilationException{
		return null;
	}
	
	public void snedSignal(Signal signal ) {
		try {
			CorePlugin plugin = (CorePlugin)ObjectFactory.getRequestPlugin(mybatisPlugin, "honey.core.plugin") ;
			plugin.notify(signal);
		} catch (PluginLifecycleException e) {
			e.printStackTrace();
		}
	}
}
